#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> radixSort(vector<int>& v)
{
    vector<vector<int>> bucket(10);

    for(int i=0;i<v.size();i++)
    {
        int digit = v[i]%10;
        bucket[digit].push_back(v[i]);
    }
    vector<vector<int>> bucket1(10);
    for(int i=0;i<bucket.size();i++)
    {
        for(int j=0;j<bucket[i].size();j++)
        {
            int digit = bucket[i][j]/10;
            bucket1[digit].push_back(bucket[i][j]);
        }
    }
    vector<int> v1;
    for(int i=0;i<bucket1.size();i++)
    {
        for(int j=0;j<bucket1[i].size();j++)
            v1.push_back(bucket1[i][j]);
    }
    return v1;

}
int main()
{
    cout<<"Enter the numbers:"<<endl;
    vector<int> v;
    int n;
    while(n!=-1)
    {
        cin>>n;
        v.push_back(n);
    }
    v.pop_back();
    v = radixSort(v);
    cout<<"Sorted vector:"<<endl;
    for(int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<endl;
    if(v.empty()||v.size()==1)
        cout<<"No need to sort"<<endl;
    return 0;
}